package com.huawei.service;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Data
@AllArgsConstructor
public class GameRuleImpl implements GameRule{
    private Integer win=0;
    private Integer lose=0;
    public  GameRuleImpl(){
        win=0;
        lose=0;
    }
    @Override
    public int judge(int judgenum){
        switch (judgenum){
            case -1:
            case 2:
                win++;
                return 1;
            case 0:
                return 2;
            case 1:
            case -2:
                lose++;
                return 3;
        }
        return 0;
    }

    @Override
    public boolean gameIsOver(int over,int round,int win,int lose) {
        if(win>(round*1.0/2)||lose>(round*1.0/2))
            return true;
        if(over>0)
            return false;
        else
            return true;
    }
}

